function TyphoonDiscMan(){
	var util = new TyphoonUtil();
	
	var tyVoltagePieChartDom;// 台风故障电压等级统计
	var windLevelBarChartDom;// 台风风力统计
	var typhoonRadiusChartDom;// 台风风圈统计
	var typhoonTimeBarChartDom;// 台风登陆时间统计
	var animatorEndTimePlus=10;

	var divId = 'affectObjDiv';
	var titleDivId = 'bottom_title';
	var titleDivTitleId = 'div_timeline_typhoon_title_title';
	var bottomTimeline = 'bottomTimeline';
	var tableId = 'typhoonEquipmentTable';
	var faultTableId = 'typhoonFaultTable';
	var nextYearBtnId = 'nextYearTyphoon';
	var svgId = 'typhoonlistSvg';
	var svgDivId = 'bottomDiv';
	var tableCurrentYearId = 'tableCurrentYear';

	var panelUtil = undefined;
	var svgUtil = undefined;

	var endYear = new Date().getFullYear();
	var endDate = new Date();
	endDate.setFullYear(endYear);
	var currentYear = new Date().getFullYear();
	var currentIndex = 0;
	var currentPanel = '';
    var isShow=true;
	var typhoons = [];
	var typhoonIndexMap = new Map();
	// 综合分析相关故障，在动画结束后展示,返回当前组织的故障数据方便单帧播放时显示当前故障信息
	// {index,analyseFaultsMap}全部电压等级
	var typhoonAnalyseFaultsMap = new Map();
	var typhoonPointFaultMap = new Map();
	var analyseFaultsMap = null;// 全部电压等级统计数据
	// {index,faults}每个台风所有的相关故障，方便在渲染总的统计图时判断是否存在故障，没有故障的就不渲染
	var typhoonFaultIndexMap = new Map();
	
	var faultPoints = [];
	var faultsData = undefined;
	var typhoonRadius = 0;
	
	var pop = undefined;
	var endPop = undefined;
	var ctyPop;// 当前台风信息pop
	
	var voltageSelector = (function(){
		var voltages = {'all':'全部','499':'500kV及以上','220':'220kV','110':'110kV'};
		var selectVoltage = 'all';
		var component;
		var listener;
		function getComponent(callback){
			component = $('<select style="width:70px;font-style:normal;"/>');
			for(var i in voltages){
				var s = voltages[i];
				var item = $('<option value="'+i+'" >'+s+'</option>');
				if(i == selectVoltage){
					item.attr('selected','selected');
				}
				component.append(item);
			}
			listener = callback;
			addListener();
			return component;
		};
		function getCurrentVoltage(){
			return selectVoltage;	
		}
		function getCurrentVoltageName(){
			return voltages[selectVoltage];	
		}
		function addListener(){
			component.on('change',function(params){
				selectVoltage = params.target.value;
				listener(selectVoltage);
			});
		}
		return {
			getComponent : getComponent,
			currentVoltage:getCurrentVoltage,
			currentVoltageName:getCurrentVoltageName,
			addListener:addListener,
		};
	})();
	this.show = function(){
		isShow = true;
		getTyphoonListData();
	};
	this.faultDetail = function(equipmentId){
		MyModal.showModal("/ui/map/dialog/typhoonFaultDialog.xhtml?equipmentId="+equipmentId);
	};
	// 用于显示当前台风详细信息以及当前故障
	this.onDrawAnimator = function(feature){
		var featureId = feature.attributes["FEATUREID"];
		if(featureId.indexOf('typhoonDLine')>-1){
			util.drawLine(feature,'typhoonDPoint');
		}
		if(featureId.indexOf('typhoonDGif')>-1){
			 // 如果渲染到gif并且是单帧渲染，则显示当前台风详细信息，并获取相关故障
			 // 不是单帧播放的就直接获取相关故障并遍历保存
			 var data=feature.attributes["DATA"];
			 typhoonDiscMan.getTyphoonFaults(data);
		}
		if(featureId.indexOf('typhoonDEnd')>-1){
			weatherLayer.setVisibility(true);
			if(endPop){
				endPop.remove();
			}
			endPop = util.addTyphoonInfoPop(feature).show();
			weatherLayer.addFeatures([util.addCircleFeature(feature.geometry,feature.data.radius7?feature.data.radius7:typhoonRadius)]);
			weatherLayer.addFeatures([util.addGifFeature(feature.geometry)]);
			// 结束后画综合分析
			drawAllChart();
		}
	};
	function drawAllChart(){
		var faults=typhoonFaultIndexMap.get(currentIndex);
		if($(elementsDiv).children().length==0 &&faults&& faults.length>0){
			drawPie();
			drawRadiusPie();
			drawWindLevelBar();
			drawTyphoonTimeBar();
			$("#piechart").parent()[0].style.zIndex=19999;
		}
	}
	// 综合图表分析
	// 添加放大图标
	function addChartToolBtn(chartInstance,chartType){
		var option=chartInstance.getOption();
		var toolboxFeature=option.toolbox.feature;
		for(var name in toolboxFeature){
			delete toolboxFeature[name];
		}
		
		chartInstance.addToolButton("myMaxTool",{
			    title:"放大",
                show:true,
				icon:"image:///resources/img/max.png",
				onclick:function(){
					openMaxChart(chartType);
				}
        });
	}
	function drawPie(){
		// 创建图表 div, 设置其基本属性, 并添加到 Elements 图层
		tyVoltagePieChartDom = document.createElement("div");
		tyVoltagePieChartDom.id = "piechart";
		tyVoltagePieChartDom.style.width = "300px";
		tyVoltagePieChartDom.style.height = "240px";
		tyVoltagePieChartDom.style.position = "absolute";
		tyVoltagePieChartDom.style.opacity = 0.8;
		elementsDiv.appendChild(tyVoltagePieChartDom);
		// 图表位置
		tyVoltagePieChartDom.style.left =  "100px";
		tyVoltagePieChartDom.style.top= "450px";
		// 图表背景颜色
		tyVoltagePieChartDom.style.backgroundColor = "#F4F3F0";
		tyVoltagePieChartDom.style.display = "block";
		var pie = new Pie([tyVoltagePieChartDom]);
		pie.setPie([['500kV',analyseFaultsMap["faults500kv"].length],['220kV',analyseFaultsMap["faults220kv"].length]]);
		var option = pie.getOption();
		pie.setTitle("故障设备电压等级");
		pie.setTitlePosition("center");
		option.legend.show=false;
		option.series[0].label.normal.position='inner';
		option.series[0].label.normal.formatter="{b}:{c}";
		option.series[0].radius="60%";
		option.tooltip.formatter="{b} : {c} ({d}%)";
		addChartToolBtn(pie,"voltage");
		pie.show();
	}
	function drawRadiusPie(){
		typhoonRadiusChartDom = document.createElement("div");
		typhoonRadiusChartDom.id = "typhoonRadius";
		typhoonRadiusChartDom.style.width = "320px";
		typhoonRadiusChartDom.style.height = "240px";
		typhoonRadiusChartDom.style.position = "absolute";
		typhoonRadiusChartDom.style.opacity = 0.8;
		elementsDiv.appendChild(typhoonRadiusChartDom);
		// 图表位置
		typhoonRadiusChartDom.style.left =  "400px";
		typhoonRadiusChartDom.style.top= "450px";
		// 图表背景颜色
		typhoonRadiusChartDom.style.backgroundColor = "#F4F3F0";
		typhoonRadiusChartDom.style.display = "block";
		var pie = new Pie([typhoonRadiusChartDom]);
		pie.setPie([['7级',analyseFaultsMap["faults7Radius"].length],['10级',analyseFaultsMap["faults10Radius"].length],['12级',analyseFaultsMap["faults12Radius"].length],['无地理信息',analyseFaultsMap["radiusUnknown"].length],['小于7级',analyseFaultsMap["radiusLe7"].length]]);
		var option = pie.getOption();
		option.legend.show=false;
		// option.series[0].label.normal.position='inner';
		option.series[0].label.normal.formatter="{b}:{c}";
		option.series[0].radius="60%";
		option.tooltip.formatter="{b} : {c} ({d}%)";
		pie.setTitle("台风风圈等级");
		pie.setTitlePosition("center");
		addChartToolBtn(pie,"radius");
		pie.show();
	}
	function drawWindLevelBar(){
		windLevelBarChartDom = document.createElement("div");
		windLevelBarChartDom.id = "typhoonlevel";
		windLevelBarChartDom.style.width = "400px";
		windLevelBarChartDom.style.height = "240px";
		windLevelBarChartDom.style.position = "absolute";
		windLevelBarChartDom.style.opacity = 0.8;
		elementsDiv.appendChild(windLevelBarChartDom);
		// 图表位置
		windLevelBarChartDom.style.left =  "720px";
		windLevelBarChartDom.style.top= "450px";
		// 图表背景颜色
		windLevelBarChartDom.style.backgroundColor = "#F4F3F0";
		windLevelBarChartDom.style.display = "block";
		
		var tys = analyseFaultsMap.tylevel;
		
		var xAxisData = [];
			var yAxisData =[]; 
		for(var i in tys){
			if(tys[i] > 0){
				xAxisData.push(i);
				yAxisData.push(tys[i]);
			}
		}
		var bar = new CategoryBar([windLevelBarChartDom]);
		bar.setxAxis(xAxisData);
		bar.setyAxis(yAxisData);
		bar.setxAxisTitle("风力");
		bar.setyAxisTitle("故障次数");
		bar.setyAxisName("故障次数");
		bar.setTitle("台风风力等级");
		bar.setTitlePosition("center");
		var option = bar.getOption();
		option.legend.show=false;
		addChartToolBtn(bar,"windLevel");
		bar.show();
	}
	function drawTyphoonTimeBar(){
		typhoonTimeBarChartDom = document.createElement("div");
		typhoonTimeBarChartDom.id = "typhoonTime";
		typhoonTimeBarChartDom.style.width = "400px";
		typhoonTimeBarChartDom.style.height = "240px";
		typhoonTimeBarChartDom.style.position = "absolute";
		typhoonTimeBarChartDom.style.opacity = 0.8;
		elementsDiv.appendChild(typhoonTimeBarChartDom);
		// 图表位置
		typhoonTimeBarChartDom.style.left =  "1120px";
		typhoonTimeBarChartDom.style.top= "450px";
		// 图表背景颜色
		typhoonTimeBarChartDom.style.backgroundColor = "#F4F3F0";
		typhoonTimeBarChartDom.style.display = "block";
		
		var tys = analyseFaultsMap.tyTime;
		
		var xAxisData = [];
		var yAxisData =[]; 
		for(var i in tys){
			if(tys[i].count > 0){
				xAxisData.push(tys[i].time);
				yAxisData.push(tys[i].count);
			}
		}
		var bar = new CategoryBar([typhoonTimeBarChartDom]);
		bar.setxAxis(xAxisData);
		bar.setyAxis(yAxisData);
		bar.setxAxisTitle("时间");
		bar.setyAxisTitle("故障次数");
		bar.setyAxisName("故障次数");
		var option = bar.getOption();
		option.legend.show=false;
		option.xAxis[0].axisLabel.rotate='-90';
		option.xAxis[0].axisLabel.interval='0';
		bar.setTitle("台风登陆时间");
		bar.setTitlePosition("center");
		addChartToolBtn(bar,"typhoonTime");
		bar.show();
	}
	// 放大chart
	function openMaxChart(chartType){
		var currentTyphoonId=typhoons[currentIndex].tid;
		switch(chartType){
		case "voltage":
			MyModal.showModal("/ui/map/dialog/typhoon/typhoonFaultVolDlg.xhtml?tid="+currentTyphoonId);
			break;
		case "radius":
			MyModal.showModal("/ui/map/dialog/typhoon/typhoonFaultRadiusDlg.xhtml?tid="+currentTyphoonId);
			break;
		case "windLevel":
			MyModal.showModal("/ui/map/dialog/typhoon/typhoonFaultWindLevelDlg.xhtml?tid="+currentTyphoonId);
			break;
		case "typhoonTime":
			MyModal.showModal("/ui/map/dialog/typhoon/typhoonFaultTimeDlg.xhtml?tid="+currentTyphoonId);
			break;
		}
		
	}
	// 用于显示当前台风详细信息以及当前故障
	this.featureRendered=function(feature){
		var featureId = feature.attributes["FEATUREID"];
		if(featureId.indexOf('typhoonDCircle')>-1 && isDrawOne){
			// 单帧播放时，暂停播放并标红当前故障线路
			
			var ct=animatorLayer.animator.getCurrentTime();
			var et=animatorLayer.animator.getEndTime()-animatorEndTimePlus;
			if(ct >= et-2 && ct <= et){
				isDrawOne =false
			} else {
				animatorLayer.animator.pause();
			}
		}
	}
	this.onSelectPoint = function(e){
		if(e.data.type && e.data.type.indexOf('Point')>-1){
			var data = e.geometry.data;
			typhoonDiscMan.getTyphoonFaults(data);
		}
	};
	this.lastYear = function(){
		currentYear --;
		currentIndex = 0;
		getTyphoonListData();
	};
	this.nextYear = function(){
		currentYear ++;
		currentIndex = 0;
		getTyphoonListData();
	};
	this.openFaultListDialog = function(tid){
		MyModal.showModal("/ui/map/dialog/typhoonFaultDialog.xhtml?tid="+tid+"&voltage="+voltageSelector.currentVoltage());
	};
	this.hide = function(){
		$('#'+titleDivId).css('display','none');
		$('#'+svgDivId).css('display','none');
		if(panelUtil){
			panelUtil.clearAndHide();
		}
		selectedLayer.removeAllFeatures();
		animatorLayer.removeAllFeatures();
		weatherLayer.removeAllFeatures();
		map.removeAllPopup();
		isShow=false;
	};
	this.onHoverPoint = function(feature){
		var type = feature.data.type;
		if (type && type.indexOf('Point') > -1) {
			if (pop) {
				pop.remove();
			}
			pop = util.addTyphoonPointPop(feature);
			pop.show();
			var data = feature.geometry.data;
			var r = data.radius7;
			if (!r) {
				r = 100;
			}
			removeFeatureByType('blueCircle',weatherLayer);
			var circle = util.addCircleFeature(
					feature.geometry, r,0,'blueCircle');
			circle.style.fillOpacity = 0.1;
			circle.style.fillColor = 'blue';
			weatherLayer.addFeatures([ circle ]);
		}
	};
	this.onOutPoint = function(feature){
		if (pop) {
			pop.remove();
		}
		removeFeatureByType('blueCircle',weatherLayer);
	};
	function removeFeatureByType(type,layer){
		var fs = layer.features;
		var ff = [];
		if(fs){
			for(var i=0;i< fs.length;i++){
				if(fs[i].data && fs[i].data.FEATUREID == type){
					ff.push(fs[i]);
				};
			}
			layer.removeFeatures(ff);
		}
	}
	function showTitle(){
		var title = $('#'+titleDivId);
		title.css('display','block');
		title.html('');
		var ul = $('<div class="btn-group"></div>');
		ul.append('<button class="btn btn-primary" onclick="typhoonDiscMan.lastYear()"><i class="fa fa-chevron-left" /></button>');
		ul.append('<button class="btn btn-primary" id="'+titleDivTitleId+'">'+currentYear+'</button>');
		if(currentYear < endYear){
			ul.append('<button class="btn btn-primary" onclick="typhoonDiscMan.nextYear()"><i class="fa fa-chevron-right" /></button>');
		}else{
			ul.append('<button class="btn btn-primary disabled"><i class="fa fa-chevron-right"/></button>');
		}
		title.append(ul);
		setTimePicker(titleDivTitleId,'top-right');
	}
	function showSvg(){
		var svgDiv = $('#'+svgDivId);
		svgDiv.css('display','block');
		if(typhoons.length>0){
			$('#'+bottomTimeline).html('<div style="height: 100px; width: 100%;"><svg id="typhoonlistSvg" style="overflow: hidden; position: relative;" ></svg></div>');
			var svg = $('#'+svgId);
			svg.height(svgDiv.height());
			svg.width(svgDiv.width());
			svgUtil = new TyphoonTimeLine(typhoons,svgId);
			svgUtil.show();
		}else{
			$('#'+bottomTimeline).html(addNoInfo("本年度无台风。"));
		}
	}
	function addNoInfo(text){
		var info = $(
				'<div style="margin:0;height:100%;width:100%;background:none;">'
				+'<div class="col-md-12" style="text-align:center;padding-top:20px;">'
				+'<i class="fa fa-smile-o"  style="font-size:40px !important;color:green"></i>'
				+'<p class="text-success">'+text+'</p>'
				+'</div>'
				+'</div>');
		return info;
	};
	this.hideChart=function(){
		$(elementsDiv).empty();
	}
	function show(){
		clearAll();
		isDrawOne=false;
		var div = $('#'+divId);
		div.css('display','block');
		showTitle();
		showSvg();
		faultPoints = [];
		if(typhoons.length>0){
			div.addClass('box-danger');
			div.removeClass('box-success');
			// drawTyphoon(currentIndex);
		}else{
			div.addClass('box-success');
			div.removeClass('box-danger');
			drawNoData();
		}
		selectedLayer.setVisibility(true);
		selectFeature.activate();
	}
	function initRightPanel(){
		panelUtil = new PanelTablesUtil(divId);
		panelUtil.setTitle('<i><span id="'+tableCurrentYearId+'" style="font-size:25px;margin:5px;">'+currentYear+'</span></i></span><span style="color:#97a0b3;"></span>');
		panelUtil.setTitleTool(voltageSelector.getComponent(function(params){
			getTyphoonListData();
		}));
		setTimePicker(tableCurrentYearId,'bottom-right');
		if(currentYear < endYear){
			panelUtil.setTitleTool('下一年','typhoonDiscMan.nextYear()',nextYearBtnId);
		}
		panelUtil.setTitleTool('上一年','typhoonDiscMan.lastYear()');
		panelUtil.show();
	}
	getTyphoonListData();
	function getTyphoonListData(){
		$.getJSON('/rest/TyphoonRestService/getTyphoonListByYear/'+currentYear,function(result){
			// 先拿到最近一年的台风列表。每次点击前进后退，获得各年的台风列表。
			// 点击台风的时候，后台获得本次台风数据，按时间排序，筛选地图上的数据，画台风轨迹。
			// 画一个时间轴
			typhoons = result;
			typhoons.sort(sortTyphoon);
			typhoonIndexMap.clear();
			typhoonAnalyseFaultsMap.clear();
			typhoonPointFaultMap.clear();
			typhoonFaultIndexMap.clear();
			if(!currentIndex || currentIndex>typhoons.length-1){
				currentIndex = 0;
			}
			show();
			initRightPanel();
		});
	}
	function sortTyphoon(obj1,obj2){
		return Number(obj1.tid)-Number(obj2.tid);
	}
	function drawNoData(){
		animatorLayer.removeAllFeatures();
		selectedLayer.removeAllFeatures();
		weatherLayer.removeAllFeatures();
		map.removeAllPopup();
		typhoonDiscMan.hideChart();
		drawTyphoonEquipment();
	}
	this.drawTyphoon = function(index){
		isShow=true;
		map.removeAllPopup();
		drawTyphoonPath(index);
	};
	function drawTyphoonPath(index){
		currentIndex = index;
		faultPoints = [];
		var data = typhoonIndexMap.get(currentIndex);
		analyseFaultsMap= typhoonAnalyseFaultsMap.get(currentIndex);
		if(!analyseFaultsMap){
			analyseFaultsMap={
					"faultData":new Map(),
					"faults500kv":[],
					"faults220kv":[],
					"faults7Radius":[],
					"faults10Radius":[],
					"faults12Radius":[],
					"radiusLe7":[],
					"radiusUnknown":[],
					"tylevel":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
			        "tyTime":[]
			};
			typhoonAnalyseFaultsMap.put(currentIndex,analyseFaultsMap);
		}
		
		if(!data){
			getTyphoonPoint();
		}else{
			drawTyphoonEquipment(data);
			drawTyphoonPoint(data.typhoon);
		}
	}
	function getTyphoonPoint(){
		var tid = typhoons[currentIndex].tid;
		var tyPoints;
		// 取地图面板和台风点的数据
		$.getJSON('/rest/TyphoonRestService/getTyphoonAndEquipmentByTid/'+tid+'/'+voltageSelector.currentVoltage(),function(result){
			faultsData = result.faults;// 相关故障
			tyPoints=result.typhoon;
			typhoonRadius = result.typhoonRadius;
			typhoonIndexMap.put(currentIndex,result);
			// drawTyphoonEquipment(result);
			// drawTyphoonPoint(result.typhoon);
			getFaultByTyphoonId(tid,result.typhoon,result);
		});
		
	}
	// 取所有故障，组织每个台风点相关故障数据以及最后统计数据，组织完数据开始画台风
	function getFaultByTyphoonId(tid,tyPoints,faults){
		$.getJSON('/rest/TyphoonRestService/getFaultByTyphoonId/'+tid+'/all',function(result){
			typhoonFaultIndexMap.put(currentIndex,result);
			initFaultDatas(result,tyPoints);
			drawTyphoonEquipment(faults);
			drawTyphoonPoint(tyPoints);
		});
	}
	// 组织每个台风点相关故障数据以及最终统计数据
	function initFaultDatas(tyFaults,tyPoints){
		for(var i in tyFaults){
			var typhoon=tyFaults[i].historyTyphoon;
			var faultRecord=tyFaults[i].faultRecord;
			faultRecord.radius=tyFaults[i].radius;
			if(typhoon){
				var faults=typhoonPointFaultMap.get(typhoon.id);
				if(!faults){
					faults=[];
				}
				faults.push(tyFaults[i].faultRecord);
				typhoonPointFaultMap.put(typhoon.id,faults);
			}
		}
		for(var i in tyPoints){
			var typhoonId=tyPoints[i].id;
			var faults=typhoonPointFaultMap.get(typhoonId);
			getAnalyseFaultsDatas(tyPoints[i],typhoonPointFaultMap.get(typhoonId));
		}
	}
	function changeYear(year){
		if(year != currentYear){
			currentYear = year;
			currentIndex = 0;
			getTyphoonListData();
		}
	}
	function setTimePicker(divId,pickerPosition){
		var d = new Date();
		d.setFullYear(currentYear, 0, 1);
		$('#'+divId).datetimepicker({
			format : 'yyyy',
			minView : 4,
			pickerPosition:pickerPosition,
			autoclose : true,
			todayHighlight : true,
			startView:4,
			endDate:endDate,
			initialDate:d
		}).on('changeYear', function(ev){
			changeYear( ev.date.getFullYear());
		});
	}
	function drawTyphoonEquipment(data){
		panelUtil = new PanelTablesUtil(divId);
		panelUtil.setTitle('<i><span id="'+tableCurrentYearId+'" style="font-size:25px;margin:5px;">'+currentYear+'</span></i></span><span style="color:#97a0b3;"></span>');
		panelUtil.setTitleTool(voltageSelector.getComponent(function(params){
			getTyphoonListData();
		}));
		setTimePicker(tableCurrentYearId,'bottom-right');
		if(currentYear < endYear){
			panelUtil.setTitleTool('下一年','typhoonDiscMan.nextYear()',nextYearBtnId);
		}
		panelUtil.setTitleTool('上一年','typhoonDiscMan.lastYear()');
		if(!data || data.length==0){
			panelUtil.setInfo(PanelTablesUtil.getSmileInfo('本年度无台风数据。'));
		}else{
			panelUtil.setInfo(drawTyphoonInfo(data.typhoon));
			drawTyphoonTable(data.equipments);
			drawTyphoonFaultTable(data.faults,data.typhoon[0]['id'],data.typhoon[0]['tid']);
			drawBhActDiv(panelUtil,typhoonFaultIndexMap.get(currentIndex).length,data.actRatio);
		}
		panelUtil.show();
	}
	function drawBhActDiv(panelUtil,faultSum,ratios){
		// 共发生多少故障，保护动作正确率为多少，当前系统保护状态正常个数：，异常个数：
		var div = panelUtil.getCollapsePanelEle("BhActParent", "保护动作分析", false,"typhoonDiscMan.onPanelClick(\'保护动作分析\');");
		var ratioUtil = new ProtectionActRatio();
		ratioUtil.setRatios(ratios).setFaultSum(faultSum).drawDiv(div);
	}
	function drawTyphoonInfo(typhoon){
		var ty1 = typhoon[0];
		var ty2 = typhoon[typhoon.length-1];
		var ul = $('<ul class="list-group no-margin" ></ul>');
		ul.append('<li class="list-group-item" style="border:0;padding:10px 5px !important"><span style="font-size: x-large;">'+typhoon[0].tname+'</span>'
				+'<div class="btn-group">'
				+'<input type="button" class="btn btn-primary btn-sm" value="播放" onclick="typhoonDiscMan.startAnimator()" style="margin-right:1px" ></input>'
				+'<input type="button" class="btn btn-primary btn-sm" value="快速" onclick="typhoonDiscMan.increaseSpeed()" style="margin-right:1px" ></input>'
				+'<input type="button" class="btn btn-primary btn-sm" value="慢速" onclick="typhoonDiscMan.decreaseSpeed()" style="margin-right:1px" ></input>'
				+'<input type="button" class="btn btn-primary btn-sm" value="暂停" onclick="typhoonDiscMan.pauseAnimator()" style="margin-right:1px"/>'
				+'<input type="button" class="btn btn-primary btn-sm" value="单帧" onclick="typhoonDiscMan.drawOne()" style="margin-right:1px"/>'
		+'<input type="button" class="btn btn-primary btn-sm" value="回退" onclick="typhoonDiscMan.backOne()" style="margin-right:1px"/>'
		+'<input type="button" class="btn btn-primary btn-sm" value="重播" onclick="typhoonDiscMan.replay()" style="margin-right:1px"/>'
		+'</div></li>');
		ul.append('<li class="list-group-item">开始时间：'+util.getTyphoonTimeStr(ty1)+'</li>');
		ul.append('<li class="list-group-item">结束时间：'+util.getTyphoonTimeStr(ty2)+'</li>');
		var div = $('<div></div>');
		div.append(ul);
		return div;
	}
	function getTypeNum(data){
		var res = {
				count:0
		};
		for(var i in data){
			var t = res[data[i]['etype']];
			if(!t){
				res[data[i]['etype']] = 1;
			}else{
				res[data[i]['etype']] = t+1;
			}
			if(data[i].count){
				res.count += Number(data[i].count);
			}
		}
		return res;
	}
	function drawFaultPoints(faults){
		for(var i in faults){
			if(faults[i].lon != 0 && faults[i].lat != 0){
				faultPoints.push(util.drawFaultPointFeature(faults[i]));
			}
		}
		weatherLayer.addFeatures(faultPoints);
		weatherLayer.setVisibility(true);
	}
	function drawTyphoonFaultTable(faults,typhoonId,tid){
		var dataset = getFaultDataset(faults);
		if(dataset.length==0){
			panelUtil.getCollapsePanelEle(faultTableId+'parent','相关故障',false,'typhoonDiscMan.onPanelClick(\'相关故障\')').append(addNoInfo('无相关故障'));
		}else{
			var div = panelUtil.getCollapsePanelEle(faultTableId+"parent", '相关故障<span class="pull-right" style="cursor:pointer;" onclick="typhoonDiscMan.openFaultListDialog(\''+tid+'\');">明细<span title="故障次数" style="margin-left:3px;" class="badge bg-yellow">'+dataset.length+'</span></span>', false,"typhoonDiscMan.onPanelClick(\'相关故障\');");
			var tb = $('<table id="'+faultTableId+'" class="table table-hover table-bordered"></table>');
			div.append(tb);
			var opt = MyTable.getDefaultOptions();
			opt.scrollY = '300px';
			opt.scrollCollapse = true;
			opt.autoWidth = false;
			opt.columnDefs = [{ "width": "33%", "targets": 0 },
			                  { "width": "34%", "targets": 1 },
			                  { "width": "33%", "targets": 2 },
			                  { "visible": false, "targets": [3,4,5,6,7]}];
			var table = new MyTable(tb,['时间','设备','故障原因'],opt);
			table.setDataSet(dataset);
			table.show();
			table.onRowClick(function(data){
				if (data) {
					searchSelectObj(data[7],false,true,data[6]);
				}
			});
		}
		
	}
	this.onPanelClick = function(title){
		if(currentPanel != title){
			currentPanel = title;
		}else{
			currentPanel = '';
		}
		/*
		 * if(currentPanel == '相关故障'){ drawFaultPoints(faultsData); }else{
		 * weatherLayer.removeFeatures(faultPoints); faultPoints = []; }
		 */
	};
	function getTimeStr(f){
		var d = new Date(f.time);
		return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+"-"+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
	}
	function getStr(f){
		return f?f:'';
	}
	function getFaultDataset(faults){
		var dataset = [];
		for(var f in faults){
			var fa = faults[f];
			dataset.push([getTimeStr(fa.faultTime),getStr(fa.equipment),getStr(fa.faultReson),getStr(fa.id),fa.lon,fa.lat,getStr(fa.mapSearchId),getStr(fa.mapSearchName)]);
		}
		return dataset;
	}
	function drawTyphoonTable(equipments){
		var dataset = getTableDataset(equipments);
		var num = getTypeNum(equipments);
		if(dataset.length==0){
			panelUtil.getCollapsePanelEle(tableId+'parent','受影响设备',false,'typhoonDiscMan.onPanelClick(\'受影响设备\')').append(addNoInfo('无设备受影响'));
		}else{
			var text = "受影响设备<span class='pull-right' style='font-size:10px;'><span class='badge bg-yellow' style='margin-right:3px;'>变电站   "
				+(num['变电站']?num['变电站']:0)
				+"</span><span class='badge bg-red'>线路   "+(num['线路']?num['线路']:0)+"</span></span>";
			var div = panelUtil.getCollapsePanelEle(tableId+"parent",text, false,'typhoonDiscMan.onPanelClick(\'受影响设备\')');
			if(num['count']){
				div.append('<ul class="list-group"><li class="list-group-item">历史共计发生台风故障<span style="font-size:20px;margin:5px"><i>'+typhoonFaultIndexMap.get(currentIndex).length+'</i></span>次</li></ul>');
			}
			var tb = $('<table id="'+tableId+'" class="table table-hover table-bordered"></table>');
			div.append(tb);
			var opt = MyTable.getDefaultOptions();
			opt.scrollY = '300px';
			opt.scrollCollapse = true;
			opt.autoWidth = false;
			opt.columnDefs = [{ "width": "33%", "targets": 0 },
			                  { "width": "34%", "targets": 1 },
			                  { "width": "33%", "targets": 2 },
			                  { "visible": false, "targets": [3,4]}];
			var table = new MyTable(tb,['设备名','受影响杆塔','历史故障'],opt);
			table.setDataSet(dataset);
			table.show();
			table.onRowClick(function(data){
				if (data) {
					searchSelectObj(data[0],false,true,data[3]);
				}
			});
		}
	}
	function addNoInfo(text){
		return PanelTablesUtil.getSmileInfo(text);
	};
	function getTableDataset(equipments){
		var dataset = [];
		equipments.sort(sort);
		for(var i in equipments){
			var d = equipments[i];
			var c = d['count']?Number(d['count']):0;
			var count = '<span title="台风或风偏">'+c+'次</span>';
			if(c>0){
				count += '<i class="fa fa-search pull-right" style="cursor:pointer;" onclick="typhoonDiscMan.faultDetail(\''+d['equipmentId']+'\')"></i>';
			}
			dataset.push([getStr(d.equipmentName),getStr(d.towerno),count,d.equipmentId,d.count?d.count:0]);
		}
		function sort(obj1,obj2){
			var c1 = obj1.count;
			var c2 = obj2.count;
			if(c1 && c2 && c1>0 && c2>0){
				return c2-c1;
			}else if(c1 && c1>0){
				return -1;
			}else if(c2 && c2>0){
				return 1;
			}else{
				var n1 = obj1['towerno'];
				var n2 = obj2['towerno'];
				var t1 = n1?(n1 == ''?0:1):0;
				var t2 = n2?(n2 == ''?0:1):0;
				return t2-t1;
			}
		}
		return dataset;
	}
	function drawTyphoonPoint(typhoonPoints){
		animatorLayer.removeAllFeatures();
		selectedLayer.removeAllFeatures();
		weatherLayer.removeAllFeatures();
		typhoonDiscMan.hideChart();
		animatorLayer.animator.setCurrentTime(0);
		animatorLayer.animator.setSpeed(0.5);
		if(pop){
			map.removePopup(pop);
		}
		if(typhoonPoints.length>0){
			var features = [];
			var lastColor = '';
			for(var i = 1,len = typhoonPoints.length;i<len;i++){
				var style = util.getStyle(typhoonPoints[i-1].windlevel);
				var radius = 6;
				if(style.fillColor != lastColor){
					radius = 8;
					lastColor = style.fillColor;
				}
				features.push(util.addLineFeature(typhoonPoints[i-1],typhoonPoints[i],i,radius,'typhoonDLine'+i));
				var lastPoint = new SuperMap.Geometry.Point(typhoonPoints[i].lon,typhoonPoints[i].lat);
				lastPoint.data=typhoonPoints[i];// 方便给gif的feature添加data,后续显示实时情况
				lastPoint.data["typid"]=typhoonPoints[i-1].id;
				features.push(util.addGifFeature(lastPoint,i,'typhoonDGif'));
				var radius = typhoonPoints[i]['radius7'];
				var radius10=typhoonPoints[i]['radius10'];
				if(!radius){
					radius = typhoonPoints[i-1]['radius7']*(typhoonPoints[i].windlevel/typhoonPoints[i-1].windlevel)
					typhoonPoints[i]['radius7'] = radius.toFixed(0);
				}
				if(!radius10){
					radius10 = typhoonPoints[i-1]['radius10']*(typhoonPoints[i].windlevel/typhoonPoints[i-1].windlevel)
					typhoonPoints[i]['radius10'] = radius10.toFixed(0);
				}
				features.push(util.addCircleFeature(lastPoint,radius?radius:typhoonRadius,i,'typhoonDCircle'));
			}
			
			features.push(util.addEndPointFeature(typhoonPoints[Number(i-1)],Number(i)-1,'typhoonDEnd'));
			animatorLayer.addFeatures(features);
			
			map.setCenter(new SuperMap.LonLat(typhoonPoints[0].lon, typhoonPoints[0].lat), 6);
			animatorLayer.animator.setEndTime(Number(i)+animatorEndTimePlus);
			animatorLayer.animator.start();
		}
	}
	// 开始播放动画
	this.startAnimator=function(){
		isDrawOne=false;
		animatorLayer.animator.setReverse(false);
		animatorLayer.animator.setSpeed(0.5);
		animatorLayer.animator.start();
	}
	this.increaseSpeed=function(){
		animatorLayer.animator.setSpeed(animatorLayer.animator.getSpeed()*2);
	}
	this.decreaseSpeed=function(){
		animatorLayer.animator.setSpeed(animatorLayer.animator.getSpeed()*0.5);
	}
	// 重新播放动画
	this.replay=function(){
		isDrawOne=false;
		var data = typhoonIndexMap.get(currentIndex);
		map.removeAllPopup();
		typhoonDiscMan.hideChart();
		drawTyphoonPoint(data.typhoon);
	}
	

	// 暂停播放动画
	this.pauseAnimator=function(){
		animatorLayer.animator.pause();
	}
	var isDrawOne=false;
	// 单帧播放
	this.drawOne=function(){
		// 当前播放的时间
		var ct=animatorLayer.animator.getCurrentTime();
		// 最后播放时间
		var et=animatorLayer.animator.getEndTime()-animatorEndTimePlus;
		// 如果不是单帧播放并且当前时间小于最后两次播放，可暂停
		if(!isDrawOne && ct < et-2){
			animatorLayer.animator.pause();
			isDrawOne=true;
		}
		// 如果是单帧播放并且当前时间小于最后两次播放，可播放
		animatorLayer.animator.setSpeed(1);
		animatorLayer.animator.setReverse(false);
		animatorLayer.animator.toggle();
	}
	this.backOne=function(){
		isDrawOne=true;
		animatorLayer.animator.setReverse(true);
		animatorLayer.animator.start();
	}
	// 获取相关故障，
	this.getTyphoonFaults=function(ctydata){
		var result = typhoonPointFaultMap.get(ctydata.id);
		renderedPath(ctydata,result);
	}
	function renderedPath(ctydata,result){
		clearSearchObj();
		drawFaultLines(result);
		renderCPop(ctydata);
	}
	function getAnalyseFaultsDatas(ctyData,faults){
		// 每个台风点的相关故障信息，受电压等级控制
		var cFaultsMap={"kv500":[],"kv220":[],"radius12faults":[],"radius10faults":[],"radius7faults":[],"radiusLe7":[],"radiusUnknown":[]};
		if(!faults){
			// 如果没有故障
			analyseFaultsMap.faultData.put(ctyData.id,cFaultsMap);
			return;
		}
		for(var i in faults){
			getCFaultsMap(faults[i],cFaultsMap);
			var radius=faults[i].radius;// 风圈等级,0表示大于7级
			switch (radius){
				case 0:
					// 大于7级
					faults[i]["radius"]="";
					analyseFaultsMap.radiusLe7.push(faults[i]);
					break;
				case 7:
					analyseFaultsMap.faults7Radius.push(faults[i]);
					break;
				case 10:
					analyseFaultsMap.faults10Radius.push(faults[i]);
					break;
				case 12:
					analyseFaultsMap.faults12Radius.push(faults[i]);
					break;
				default:
					// 未知位置
					faults[i]["radius"]="";
				    analyseFaultsMap.radiusUnknown.push(faults[i]);
			    	break;
			}
			if(faults[i].voltage == 220){
				analyseFaultsMap.faults220kv.push(faults[i]);
			} else {
				analyseFaultsMap.faults500kv.push(faults[i])
			}
		}
		var tylevelIndex = ctyData['windlevel'];
		var tylevelCount = faults.length;
		analyseFaultsMap.tylevel[tylevelIndex]+=tylevelCount;
		var time=util.getDayHourTime(ctyData['updateTime']);
		analyseFaultsMap.tyTime.push({"time":time,"count":tylevelCount});
		analyseFaultsMap.faultData.put(ctyData.id,cFaultsMap);
	}
	
	function getCFaultsMap(fault,cFaultsMap){
		var selectedVol=voltageSelector.currentVoltage();// 选择的电压等级
		if(isFitSelectedVol(fault,selectedVol)){
			var radius=fault.radius;// 风圈等级,0表示大于7级
			switch (radius){
			case 0:
				// 大于7级
		    	cFaultsMap.radiusLe7.push(fault);
				break;
			case 7:
				cFaultsMap.radius7faults.push(fault);
				break;
			case 10:
				cFaultsMap.radius10faults.push(fault);
				break;
			case 12:
				cFaultsMap.radius12faults.push(fault);
				break;
			default:
				// 未知位置
			    cFaultsMap.radiusUnknown.push(fault);
		    	break;
		  }
		if(fault.voltage == 220){
			cFaultsMap.kv220.push(fault);
		} else{
			cFaultsMap.kv500.push(fault)
		}
	  }
	}
	
	// 判断一条故障是否符合选择的电压等级
	function isFitSelectedVol(fault,selectedVol){
		if(selectedVol=="all"||(selectedVol=="499"&&fault.voltage>=selectedVol)||selectedVol==fault.voltage){
			return true;
		}
		return false;
	}
// 标红故障线路
	function drawFaultLines(lines){
		for(var i in lines){
			var name = lines[i].equipment;
			var id = lines[i].equipment_id;
			if("线路" != lines[i].etype){
				name = lines[i].stationName;
				id = lines[i].stationId;
			}
			searchSelectObj(lines[i].equipment,false,true,lines[i].equipment_id,false);
		}
	}
	var info;// 当前台风信息
	// 渲染当前台风信息和当前故障的div
	function renderCPop(ctyData){
		var cFaultsMap = analyseFaultsMap.faultData.get(ctyData.id);
		var lonlat = map.getLonLatFromPixel(new SuperMap.Pixel(100,30));
		var data =ctyData;
		var radius7 = data['radius7']?getColorTxt(data['radius7'])+'公里':'';
		var radius10 = data['radius10']?getColorTxt(data['radius10'])+'公里':'';
		var windlevel = data['windlevel']?getColorTxt(data['windlevel'])+'级':'';
		var strength = data['strength']?getColorTxt(data['strength']):'';
		var pressure = data['pressure']?getColorTxt(data['pressure'])+'百帕':'';
		var wndmax = data['wndmax']?getColorTxt(data['wndmax'])+'米/秒':'';
		var typoint =  new SuperMap.Geometry.Point(data['lon'], data['lat']);
		var kv500=cFaultsMap["kv500"];
		var kv220=cFaultsMap["kv220"];
		var radius10faults=cFaultsMap["radius10faults"];
		var radius7faults=cFaultsMap["radius7faults"];
		var radiusLe7=cFaultsMap["radiusLe7"];
		info="<div style='font-size:x-large;padding:5px;font-style:italic'>"
			+util.getTyphoonTimeStr(ctyData)
			+"</div><div style='padding:5px;font-size:12px'>风力:"+windlevel
			+"&nbsp;&nbsp;&nbsp;&nbsp; 压强:"+pressure
			+"&nbsp;&nbsp;&nbsp;&nbsp; 最大风速:"+wndmax
			+"<br/>七级风圈:"+radius7
			+"&nbsp;&nbsp;&nbsp;&nbsp;十级风圈:"+radius10
			+"<br/>故障数量总计:&nbsp;"+getColorTxt(kv500.length+kv220.length)
			+"<br/>10级风圈:&nbsp;"+getColorTxt(radius10faults.length)
			+"&nbsp;&nbsp;&nbsp;&nbsp;7级风圈:&nbsp;"+getColorTxt(radius7faults.length)
			+"&nbsp;&nbsp;&nbsp;&nbsp;小于7级:&nbsp;"+getColorTxt(radiusLe7.length)
		    +"<br/>500kV:&nbsp;"+getColorTxt(kv500.length)
		    +"&nbsp;&nbsp;&nbsp;&nbsp;220kV:&nbsp;"+getColorTxt(kv220.length)
		    +"</div>";
		
		
		if(kv500.length>0){
			info+="<span style='font-size:16px'>500kV</span><br/>";
			info+="<ul class='faultlist' style='padding:10px;border:1px solid #ddd;font-size:12px'>";
			for(var i in kv500){
				info+="<li>"+genSpanWidth(util.getHourTime(kv500[i].faultTime),'50px')
			        +genSpanWidth(kv500[i].equipment,'150px');
			    if(kv500[i]["radius"]){
			    	info+=genSpanWidth(kv500[i]["radius"]+"级",'50px');
			    }
			    info+="</li>";
			}
				info+="</ul>";
		}
		if(kv220.length>0){
			info+="<span style='font-size:16px'>220kV</span><br/>";
			info+="<ul class='faultlist' style='padding:10px;border:1px solid #ddd;font-size:12px'>";
			for(var i in kv220){
				info+="<li>"+genSpanWidth(util.getHourTime(kv220[i].faultTime),'50px')
				    +genSpanWidth(kv220[i].equipment,'150px');
			    if(kv220[i]["radius"]){
			    	info+=genSpanWidth(kv220[i]["radius"]+"级",'50px');
			    }
			    info+="</li>";
			}
			info+="</ul>";
		}
		// info+="</div>";
		if (ctyPop) {
			map.removePopup(ctyPop);
		 }
		ctyPop = new SuperMap.Popup("cty",
                new SuperMap.LonLat(lonlat.lon,lonlat.lat),
                new SuperMap.Size(290,410),
                info,
                true);
		ctyPop.keepInMap=true;
		// ctyPop.setOpacity(0.9);
		ctyPop.setBorder("1px solid #3c8dbc");
		map.addPopup(ctyPop);
		$(".faultlist").slimScroll({ height: '100px' });
	}
	this.refreshPop=function(){
		var lonlat = map.getLonLatFromPixel(new SuperMap.Pixel(100,30));
		if (ctyPop) {
			map.removePopup(ctyPop);
		 }
		ctyPop = new SuperMap.Popup("cty",
                new SuperMap.LonLat(lonlat.lon,lonlat.lat),
                new SuperMap.Size(290,410),
                info,
                true);
		ctyPop.keepInMap=true;
		// ctyPop.setOpacity(0.9);
		ctyPop.setBorder("1px solid #3c8dbc");
		map.addPopup(ctyPop);
		$(".faultlist").slimScroll({ height: '100px' });
	}
	this.isShow=function(){
		return isShow;
	}
	var getColorTxt = function(txt){
		return "<span style='color:blue;font-size:16px'>"+txt+"</span>";
	}
	var genSpanWidth=function(txt,w){
		return "<span style='display:inline-block;width:"+w+"'>"+txt+"</span>";
	}
	
}
function TyphoonUtil(){
	this.drawLine = function(feature,type){
		var p1 = feature.geometry.components[0];
		var p2 = feature.geometry.components[1];
		var pointVector = new SuperMap.Feature.Vector(p1);
		pointVector.style= p1.style;
		pointVector.data.type= type;

		var pointVector2 = new SuperMap.Feature.Vector(p2);
		pointVector2.style= p2.style;
		pointVector2.data.type= type;

		var points=[p1,p2];
		var line = new SuperMap.Geometry.LineString(points);
		var lineVector = new SuperMap.Feature.Vector(line);
		lineVector.style = feature.style;
		selectedLayer.addFeatures([lineVector,pointVector,pointVector2]);
	};
	this.drawFaultPointFeature = function(fault){
		var point= new SuperMap.Geometry.Point(fault.lon,fault.lat);
        var pointVector = new SuperMap.Feature.Vector(point);
        pointVector.style={
            fillColor:"red",
            strokeColor:"yellow",
            pointRadius:6
        };
		return pointVector;
	};
	this.addEndPointFeature = function(data,time,featureId){
		var end = new SuperMap.Feature.Vector(
				new SuperMap.Geometry.Point(data.lon,data.lat),
				{
					FEATUREID:featureId,
					TIME:time
				},
				{pointRadius:2}
		);
		end.data = data;
		return end;
	};
	this.addLineFeature = function(point1,point2,time,radius,featureId,lineType,color){
		var ps = [point1,point2];
		var arrP1 = [];
		var styles = [];
		for(var a=0;a<ps.length;a++){
			var point = new SuperMap.Geometry.Point(ps[a].lon,ps[a].lat);
			point.data = ps[a];

			var style = getStyle(ps[a].windlevel);
			point.style = style;
			arrP1.push(point);
			styles.push(style);
		}
		styles[0].pointRadius = radius;
		if(styles[1].fillColor != styles[0].fillColor){
			styles[1].pointRadius = 8;
		}
		var lineString = new SuperMap.Geometry.LineString(arrP1);

		var lineFeature = new SuperMap.Feature.Vector(lineString,{
			FEATUREID:featureId,
			TIME:time
		},{
			strokeColor : color?color:lineType?'orange':'#0076c9',
			strokeWidth: lineType? 1 : 2 ,
			strokeDashstyle:lineType?lineType:'solid'
		});
		return lineFeature;
	};
	this.addGifFeature = function(point,time,featureId){
		// console.log(point);
		var gif = new SuperMap.Feature.Vector(
				point,
				{
					FEATUREID:featureId,
					TIME:time,
					DATA:point.data
				},
				{
					externalGraphic: "/resources/img/weather/typhoon2.gif",
					graphicWidth:50,
					allowRotate:true,
					graphicHeight: 50,
					graphicOpacity:0.9,
				}
		);
		return gif;
	};
	this.addCircleFeature = function(point,radius,time,featureId){
		var circleP = createCircle(point,radius,256,360,0);
		var pinkCircle= new SuperMap.Feature.Vector(circleP,{
			FEATUREID:featureId,
			TIME:time
		},{
			fill:true,
			stroke:true,
			strokeColor:"#CAFF70",
			fillColor:"pink",
			strokeWidth:0.6,
			fillOpacity:0.5
		});
		pinkCircle.clickable = false;
		pinkCircle.hoverable = false;
		return pinkCircle;
	};
	this.getStyle = function(index){
		return getStyle(index);
	};
	this.addTyphoonPointPop = function(e){
		var data = e.geometry.data;
		var radius7 = data['radius7']?data['radius7']+'公里':'';
		var radius10 = data['radius10']?data['radius10']+'公里':'';
		var windlevel = data['windlevel']?data['windlevel']+'级':'';
		var strength = data['strength']?data['strength']:'';
		var pressure = data['pressure']?data['pressure']+'百帕':'';
		var wndmax = data['wndmax']?data['wndmax']+'米/秒':'';
		var pop = new Popup(e.geometry.x,e.geometry.y);
		pop.setTitle(getTyphoonTimeStr(data));
		pop.setRowContent('经纬度：'+data.lon+'°/'+data.lat+'°');
		pop.setRowContent('风力：'+windlevel);
		pop.setRowContent('等级：'+strength);
		pop.setRowContent('压强：'+pressure);
		pop.setRowContent('最大风速：'+wndmax);
		pop.setRowContent('七级风圈：'+radius7);
		pop.setRowContent('十级风圈：'+radius10);
		pop.showCloseIcon(true);
		pop.showRowOverflow(false);
		return pop;
	};
	this.addTyphoonForecastPointPop = function(e){
		var data = e.geometry.data;
		var windlevel = data['windlevel']?data['windlevel']+'级':'';
		var strength = data['tropical_hurricane_level']?data['tropical_hurricane_level']:'';
		var pressure = data['pressure']?data['pressure']+'百帕':'';
		var pop = new Popup(e.geometry.x,e.geometry.y);
		pop.setTitle('预报：'+getForecastTimeStr(data.forecast_time));
		pop.setRowContent('经纬度：'+data.lon+'°/'+data.lat+'°');
		pop.setRowContent('风力：'+windlevel);
		pop.setRowContent('等级：'+strength);
		pop.setRowContent('压强：'+pressure);
		pop.showCloseIcon(true);
		pop.showRowOverflow(false);
		return pop;
	};
	function getForecastTimeStr(f){
		var d = new Date(f.time);
		return d.getFullYear()+"年"+(d.getMonth()+1)+"月"+d.getDate()+"日"+" "+d.getHours()+"时";
	}
	this.addTyphoonInfoPop = function(e,popId,notMoveMap){
		return addTyphoonInfoPop(e,popId,notMoveMap);
	};
	function addTyphoonInfoPop(e,popId,notMoveMap){
		var data = e.data;
		var pop = new Popup(e.geometry.x,e.geometry.y);
		pop.setTitle(data.tname);
		var c = getTyphoonTimeStr(data);
		pop.setRowContent(c);
		pop.setId(popId);
		pop.setAutoSize(true);
		pop.showRowOverflow(false);
		pop.showHoverEffect(false);
		if(notMoveMap){
			pop.panMapIfOutOfView = false;
		}
		return pop;
	}
	this.createCircle = function(origin, radius, sides,r,angel){
		createCircle(origin, radius, sides,r,angel);
	};
	// [Point 中心点，半径公里数，边数，扇形角度，相对于中心点偏移角度]
	function createCircle(origin, radius, sides,r,angel){
		// rR r*3.14/(180*边数)
		var rR = r*Math.PI/(180*sides);
		var rotatedAngle, x, y;
		var points = [];
		// 算出纬度半径
		var yradius = radius/111;
		// 经度半径
		var xradius = yradius/Math.cos(origin.y/180*Math.PI);
		for(var i=0; i<sides; ++i) {
			rotatedAngle = rR*i;
			x = origin.x + (xradius * Math.cos(rotatedAngle));
			y = origin.y + (yradius * Math.sin(rotatedAngle));
			points.push(new SuperMap.Geometry.Point(x, y));
		}
		rotatedAngle = r*Math.PI/180;
		x = origin.x + (xradius * Math.cos(rotatedAngle));
		y = origin.y + (yradius * Math.sin(rotatedAngle));
		points.push(new SuperMap.Geometry.Point(x, y));

		var ring = new SuperMap.Geometry.LinearRing(points);
		ring.rotate(parseFloat(angel),origin);
		/*
		 * var geo = new SuperMap.Geometry.Collection([ring]); geo.origin =
		 * origin; geo.radius = radius; geo.r = r; geo.angel = angel; geo.sides =
		 * sides; geo.polygonType = "Curve";
		 */
		return ring;
	}
	function getStyle(index){
		var fillColor = "";
		switch(index){
		case 17 : 
		case 16 : fillColor = 'red';break;
		case 15 : 
		case 14 : fillColor = 'rgb(250, 131, 246)';break;
		case 13 :
		case 12 : fillColor = 'rgb(250, 171, 42)';break;
		case 11 :
		case 10 : fillColor = 'rgb(248, 249, 42)';break;
		case 9 : 
		case 8 : fillColor = 'rgb(88, 138, 246)';break;
		case 7 : 
		case 6 : fillColor = 'rgb(81, 251, 82)';break;
		case 5 : 
		case 4 :
		default : fillColor = 'white';
		}
		var style = {
				fillColor:fillColor,
				pointRadius:6,
				stroke:true,
				stokeColor:'rgb(53, 52, 51);',
				stokeWidth:1,
				strokeOpacity:0.5
		};
		return style;
	}
	this.getTyphoonTimeStr = function(t){
		return getTyphoonTimeStr(t);
	};
	function getTyphoonTimeStr(t){
		return DateUtil.pattern(t.updateTime,'yyyy年MM月dd日 hh时');
	}
	this.getHourTime=function(t){
		return DateUtil.pattern(t,'hh:mm:ss');
	}
	this.getDayHourTime=function(t){
		return DateUtil.pattern(t,'dd日hh时');
	}
	this.getDistance=function( lng1, lat1,
			 lng2 , lat2) {
		var radLat1 = rad(lat1);
		var radLat2 = rad(lat2);
		var a = radLat1 - radLat2;
		var b = rad(lng1) - rad(lng2);
		var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2)
				+ Math.cos(radLat1) * Math.cos(radLat2)
				* Math.pow(Math.sin(b / 2), 2)));
		s = s * 6378.137;
		s = Math.round(s * 10000) / 10000;
		// s = s * 1000;
		return s;
	}
	function rad(d) {
		return d * Math.PI / 180.0;
	}
}
